package com.zzy.httputil;

import org.junit.Test;

import jodd.http.HttpBrowser;
import jodd.http.HttpRequest;
import jodd.http.HttpResponse;

public class HttpdemoTest {
	
	@Test
	public void  testDemo(){
		HttpResponse response = HttpRequest
		        .get("http://localhost/g-main3/index.jspx")
		        .query("userId", "10194")
		        .query("userId", "10194")
		        .queryEncoding("utf-8")
		        .send();
		System.out.println(response.bodyText());
	}
	
	@Test
	public void  postDemo(){
		//POST请求
		HttpResponse response = HttpRequest
		.post("http://localhost/g-main3/index.jspx")
		.form("userId", "10194")
		.form("userId2", "10194")//这里与get的参数传递方式不同
		.queryEncoding("utf-8")
		.send();
		System.out.println(response.bodyText());
	}
	
	
	@Test
	public void HttpBrowserTests(){
		HttpBrowser browser = new HttpBrowser();

	    HttpRequest request = HttpRequest.get("http://192.168.3.35:9081/ECPS/index.jspx");
	    browser.sendRequest(request);

	    // process the page:
	    String page = browser.getPage();
	    
	    System.out.println(page);

	    // create new request
	    HttpRequest newRequest = HttpRequest.post("");

	    browser.sendRequest(newRequest);
	}

}
